package ai.plantdata.Creation.mode.FactoryMethod.factory;

import ai.plantdata.Creation.mode.FactoryMethod.interfaces.Shape;
import ai.plantdata.Creation.mode.FactoryMethod.interfaces.impl.Circle;
import ai.plantdata.Creation.mode.FactoryMethod.interfaces.impl.Rectangle;
import ai.plantdata.Creation.mode.FactoryMethod.interfaces.impl.Square;

/**
 * @Author: WangHui
 * @Date: 2020/12/18 11:15
 * @Description:
 */
public class ShapeFactory {
    /**
     * 使用getShape方法获取形状类型的对象
     * @param shapeType
     * @return
     */
    public Shape getShape(String shapeType){
        if(shapeType == null ){
            return null;
        }
        if("CIRCLE".equalsIgnoreCase(shapeType)){
            return new Circle();
        }else if("RECTANGLE".equalsIgnoreCase(shapeType)){
            return new Rectangle();
        }else if("SQUARE".equalsIgnoreCase(shapeType)){
            return new Square();
        }
        return null;
    }
}
